﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:primitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls.Toolkit">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Brushes.xaml"/>
    </ResourceDictionary.MergedDictionaries>

  <Style TargetType="Button" x:Key="ButtonImportantStyle">
    <Setter Property="Background"
                Value="{StaticResource ImportantBrush}" />
    <Setter Property="BorderThickness"
            Value="0" />
    <Setter Property="HorizontalContentAlignment"
            Value="Center" />
    <Setter Property="Padding"
            Value="14,12" />
    <Setter Property="Foreground"
            Value="White" />
    <Setter Property="FontFamily"
            Value="Segoe WP Black" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="Button">
          <Grid>
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="CommonStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="Normal"
                                    To="Pressed"
                                    GeneratedDuration="0:0:0.1" />
                  <VisualTransition From="Pressed"
                                    To="Normal"
                                    GeneratedDuration="0:0:0.2" />
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Normal" />
                <VisualState x:Name="MouseOver" />
                <VisualState x:Name="Pressed">
                  <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="buttonTransform"
                                     Storyboard.TargetProperty="GlobalOffsetZ"
                                     Duration="0:0:0.1"
                                     To="-25">
                      <DoubleAnimation.EasingFunction>
                        <QuinticEase EasingMode="EaseOut" />
                      </DoubleAnimation.EasingFunction>
                    </DoubleAnimation>
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Border Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Padding="{TemplateBinding Padding}">
              <Border.Projection>
                <PlaneProjection x:Name="buttonTransform"
                                 GlobalOffsetZ="0" />
              </Border.Projection>

              <ContentPresenter x:Name="contentPresenter"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                Margin="0" />
            </Border>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  
    <Style TargetType="Button"
           x:Key="ButtonStyle">
        <Setter Property="Background"
                Value="{StaticResource AccentBrushDark}" />
        <Setter Property="BorderThickness"
                Value="0" />
        <Setter Property="HorizontalContentAlignment"
                Value="Center" />
        <Setter Property="Padding"
                Value="14,12" />
        <Setter Property="Foreground"
                Value="White" />
        <Setter Property="FontFamily"
                Value="Segoe WP Black" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="Normal"
                                                      To="Pressed"
                                                      GeneratedDuration="0:0:0.1" />
                                    <VisualTransition From="Pressed"
                                                      To="Normal"
                                                      GeneratedDuration="0:0:0.2" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="buttonTransform"
                                                         Storyboard.TargetProperty="GlobalOffsetZ"
                                                         Duration="0:0:0.1"
                                                         To="-25">
                                            <DoubleAnimation.EasingFunction>
                                                <QuinticEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <Border.Projection>
                                <PlaneProjection x:Name="buttonTransform"
                                                 GlobalOffsetZ="0" />
                            </Border.Projection>
                            
                            <ContentPresenter x:Name="contentPresenter"
                                              Content="{TemplateBinding Content}"
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              Margin="0" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="IconButtonStyle" TargetType="Button">
        <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="Height" Value="72" />
        <Setter Property="Width" Value="72" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Pressed"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Ellipse Stroke="{TemplateBinding Foreground}" 
                                 StrokeThickness="{StaticResource PhoneBorderThickness}"
                                 Margin="{StaticResource PhoneTouchTargetOverhang}" 
                                 x:Name="BackgroundBrush"/>
                        <Ellipse Fill="{TemplateBinding Foreground}" 
                                 Margin="{StaticResource PhoneTouchTargetOverhang}"
                                 OpacityMask="{TemplateBinding Content}"
                                 x:Name="ContentArea"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonPressedEffectNoStyle"
           TargetType="Button">
        <Setter Property="BorderThickness"
                Value="0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition From="Normal"
                                                      To="Pressed"
                                                      GeneratedDuration="0:0:0.1" />
                                    <VisualTransition From="Pressed"
                                                      To="Normal"
                                                      GeneratedDuration="0:0:0.2" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver" />
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="contentPresenterTransform"
                                                         Storyboard.TargetProperty="GlobalOffsetZ"
                                                         Duration="0:0:0.1"
                                                         To="-20">
                                            <DoubleAnimation.EasingFunction>
                                                <QuinticEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter x:Name="contentPresenter"
                                          Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          VerticalAlignment="Stretch"
                                          HorizontalAlignment="Stretch"
                                          Margin="0">
                            <ContentPresenter.Projection>
                                <PlaneProjection x:Name="contentPresenterTransform"
                                                 GlobalOffsetZ="0" />
                            </ContentPresenter.Projection>
                        </ContentPresenter>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ButtonNoStyle" TargetType="Button">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver"/>
                                <VisualState x:Name="Pressed"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              VerticalAlignment="Stretch"
                              HorizontalAlignment="Stretch"
                              Margin="0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="toolkit:ToggleSwitch" x:Key="ToggleSwitchStyle">
        <Setter Property="Background" Value="{StaticResource PhoneBackgroundBrush}"/>
        <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyLight}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
        <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="SwitchForeground" Value="{StaticResource PhoneAccentBrush}"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:ToggleSwitch">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Padding="{TemplateBinding Padding}"
                        CacheMode="BitmapCache">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Header"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.3"/>
                                        <DoubleAnimation
                                            Storyboard.TargetName="Content"
                                            Storyboard.TargetProperty="Opacity"
                                            Duration="0"
                                            To="0.3"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid Margin="12,5,36,25">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <ContentControl
                                x:Name="Header"
                                Content="{TemplateBinding Header}"
                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                FontSize="{StaticResource PhoneFontSizeNormal}"
                                Foreground="{StaticResource PhoneBorderBrush}"
                                HorizontalAlignment="Left"
                                IsTabStop="False"
                                Margin="-1,0,0,0"
                                Opacity="{TemplateBinding Opacity}"
                                VerticalAlignment="Bottom"/>
                            <ContentControl
                                x:Name="Content"
                                Grid.Row="1"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                IsTabStop="False"
                                Margin="-1,1,0,-7"
                                Opacity="{TemplateBinding Opacity}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            <primitives:ToggleSwitchButton
                                x:Name="Switch"
                                Grid.RowSpan="2"
                                Grid.Column="1"
                                Background="{TemplateBinding Background}"
                                Margin="-22,-29,-24,-28"
                                Opacity="{TemplateBinding Opacity}"
                                SwitchForeground="{TemplateBinding SwitchForeground}"
                                VerticalAlignment="Bottom"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>